import { request } from 'umi';

// 小程序配置相关API

// 获取小程序配置
export async function getMiniprogramConfig() {
  return request('/api/v1/miniprogram/config', {
    method: 'GET',
  });
}

// 更新小程序配置
export async function updateMiniprogramConfig(data) {
  return request('/api/v1/miniprogram/config', {
    method: 'PUT',
    data,
  });
}

// 小程序内容相关API

// 获取内容列表
export async function getContentList(params) {
  return request('/api/v1/miniprogram/content', {
    method: 'GET',
    params,
  });
}

// 获取单个内容
export async function getContent(id) {
  return request(`/api/v1/miniprogram/content/${id}`, {
    method: 'GET',
  });
}

// 创建内容
export async function createContent(data) {
  return request('/api/v1/miniprogram/content', {
    method: 'POST',
    data,
  });
}

// 更新内容
export async function updateContent(data) {
  return request('/api/v1/miniprogram/content', {
    method: 'PUT',
    data,
  });
}

// 删除内容
export async function deleteContent(id) {
  return request(`/api/v1/miniprogram/content/${id}`, {
    method: 'DELETE',
  });
}

// 小程序轮播图相关API

// 获取轮播图列表
export async function getBannerList(params) {
  return request('/api/v1/miniprogram/banner', {
    method: 'GET',
    params,
  });
}

// 获取单个轮播图
export async function getBanner(id) {
  return request(`/api/v1/miniprogram/banner/${id}`, {
    method: 'GET',
  });
}

// 创建轮播图
export async function createBanner(data) {
  return request('/api/v1/miniprogram/banner', {
    method: 'POST',
    data,
  });
}

// 更新轮播图
export async function updateBanner(data) {
  return request('/api/v1/miniprogram/banner', {
    method: 'PUT',
    data,
  });
}

// 删除轮播图
export async function deleteBanner(id) {
  return request(`/api/v1/miniprogram/banner/${id}`, {
    method: 'DELETE',
  });
}

// 更新轮播图排序
export async function updateBannerSort(data) {
  return request('/api/v1/miniprogram/banner/sort', {
    method: 'PUT',
    data,
  });
}